<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/1/18 0018
  Time: 上午 10:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>${sessionScope.title}</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/admin/css/x-admin.css" media="all">
</head>

<body>
<div class="x-body">
    <form class="layui-form">

        <input type="hidden" id="cname" name="id" required=""
               autocomplete="off"  value="${rec.id}" disabled="" class="layui-input">
        <input type="hidden" name="parentid" value="${parentid}">
        <div class="layui-form-item">
            <label for="cname" class="layui-form-label">
                <span class="x-red">*</span>url
            </label>
            <div class="layui-input-inline">
                <input type="text" id="cname" name="url" required="" lay-verify="required"
                       autocomplete="off" class="layui-input" value="${rec.url}">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="cname" class="layui-form-label">
                <span class="x-red">*</span>权限名称
            </label>
            <div class="layui-input-inline">
                <input type="text" id="cname" name="name" required="" lay-verify="required"
                       autocomplete="off" class="layui-input" value="${rec.name}">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="L_repass" class="layui-form-label">
            </label>
            <button  class="layui-btn" lay-filter="save" lay-submit="">
                保存
            </button>
        </div>
    </form>
</div>
<script src="/admin/lib/layui/layui.js" charset="utf-8">
</script>
<script src="/admin/js/x-layui.js" charset="utf-8">
</script>
<script>
    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form()
            ,layer = layui.layer;

        //监听提交
        form.on('submit(save)', function(data){
            console.log(data);
            //发异步，把数据提交给php
            $.ajax({
                url:'/adminSystem/saveAuthorizationButton',
                type:'POST', //GET
                async:true,    //或false,是否异步
                data:data.field,
                timeout:5000,    //超时时间
                dataType:'json',    //返回的数据格式：json/xml/html/script/jsonp/text
                beforeSend:function(xhr){1
                    /*console.log(xhr)
                     console.log('发送前')*/
                },
                success:function(reData){
                    if ("true"==reData.code){
                        layer.alert("保存成功", {icon: 6},function () {
                            // 获得frame索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.layer.close(index);
                        });
                    }else {
                        layer.alert("保存失败", {icon: 5});
                    }
                },
                error:function(xhr,textStatus){
                    console.log('错误')
                    console.log(xhr)
                    console.log(textStatus)
                },
                complete:function(){
                    //console.log('结束')
                }
            });

            return false;
        });
        /**
         * 隐藏id
         */
        $(document).ready(function(){


            $("#id01").hide();
        })

    });

</script>


</body>

</html>
